<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.meila.cms.entity.User"%>
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 
    User user=((User) session.getAttribute("loginUser"));
    request.setAttribute("user", user);
%>

<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>新建设计</title>
  
    
  </head>
  
  <body class="client-body">
  	<jsp:include page="../common/client-head.jsp"></jsp:include>

  	<div class="client-content">
  		<jsp:include page="../common/client-leftMenu.jsp"></jsp:include>
  	
  		<div class="client-contentBox">
  			<div class="newDedign-content">
  				<div class="newDedign-head">新建设计</div>
  			</div>
  			
  			<form class="form-horizontal newDedign-content" style="display: block;">
			  <div class="form-group">
			    <label class="col-sm-2 control-label">名称</label>
			    <div class="col-sm-7">
			     	<input type="text" class="form-control" name="designname"  id="designname"/>
			    </div>
			    <div class="col-sm-3" onclick="create()">
		     	    <a class="btn btn2 a-white"   id="btn">创建</a>
			    </div>
			  </div>
			  
			  <div class="form-group">
			    <div class="col-sm-offset-2 col-sm-10">
				      <c:if test="${user.remianSpace<0}">
				          <i class="fa fa-unlock-alt"></i>
				                    私有空间不足，您只能创建公开文件，您也可以扩容
				      </c:if>
			    </div>
			  </div>
		  </form>
  		
  		</div>
  	</div>
	<script type="text/javascript">
		function create(){
		  
		  var designname=$('#designname').val();
		  
		  if(designname==""){
		       jAlert("设计名不能为空","提示");
		       return false;
		  }
		  if(designname.length > 20){
		       jAlert("设计名不能超过20个字符","提示");
		       return false;
		  }
		  
		   $.ajax({  
		        type : "POST",  
		        url : CONTEXT_PATH+'common/checkNameUnique',  
		        dataType : "json",  
		        cache : false,  
		 	    data:{propertyvalue:designname,category:'CarDesignName',where:' and del=0 and userid=${user.id}'},
		        success : function(data) {
		          
                   if(data.result==true){
              		    jAlert(data.msg,"提示");
	                    return;
	               }else{
		                window.location.href=CONTEXT_PATH+"front/carDesign/addCarDesign?designname="+designname;
		           }
	 
		        }  
	      }); 
		  
		}
	</script>
  </body>
</html>
